/**
 *	\file
 *	\brief represents a single label stored in a LabelHashTable
 *
 * 	\date Sep 12, 2013
 * 	\author koldar
 *	\version 1.0
 */

#ifndef LABEL_H_
#define LABEL_H_

#include <stdio.h>
#include "LabelClassType.h"

/**represents a label which can be added as "value" in a hashtable
 *
 */
typedef struct Label {
	char* name; //!< the name of the label
	LabelClassType type; //!< the type of the label
} Label;

/**pointer to a Label to improve readability
 *
 */
typedef Label* Plabel;

/**initialize a new Label
 *
 * \pre
 *  \li _name not  NULL;
 * \post
 *  \li a new LabelElement is stored in memory. To free it, you can use freeLabel()
 *
 * @param _name the name of the label to create
 * @param _type the type of the label to create
 * @return a pointer to the newly created LabelElement
 */
Plabel initLabel(char* _name,LabelClassType _type);

/**free the current label.
 * Why the very string describing the label (the memory area pointed by name) is not freed?
 * Because probably that area is already pointed by the syntax tree (the symbol table is merely using the syntax tree to create
 * the table). So if this function freed the area, the same area would be freed a <b>second</b> time when calling freeSyntaxTree(), creating memory leaks.
 * To avoid this problem, the post condition has been added
 *
 * \pre
 *  \li pobj not NULL
 * \post
 *  \li the area pointed by the field "name" is <b>not</b> freed.
 *  \li this Label is deallocate corrrectly form the memory
 *
 * @param pobj the label to remove
 */
void freeLabel(Plabel pobj);

/**prints a string representation of the Label
 *
 * \post
 *  \li the "label_name (label_type_class)" is printed on the file f
 *
 * @param f the write to write the string on
 * @param pobj the Label to compute
 */
void printLabel(FILE* f,Plabel pobj);

#endif /* LABEL_H_ */
